<template>
	<view class="topBar" :style="'height:'+ height3 + 'px'">
		<view class="status" :style="'height:'+ height1 + 'px'"></view>
		<view class="content flex-row-between" :style="'width:'+ width + 'px;height:'+ height2 + 'px;padding: 0 10rpx 0 10rpx;'">
			<uni-icons class="icon font-b" type="arrowleft" size="20" color="#000000" @click="goBack"></uni-icons>
			<view class="font14">{{title}}</view>
			<view>
				<slot></slot>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			// 返回的链接
			backUrl: {
				type: String,
				default: ''
			},
			// 标题
			title: {
				type: String,
				default: ''
			},
		},

		data() {
			return {
				height1: this.statusBar, // 状态栏的高度
				height2: this.customBarHeight - this.statusBar, // 胶囊的高度
				height3: this.customBarHeight, // 状态栏+胶囊的高度
				width: this.customBarWidth, // 胶囊左侧的宽度
			};
		},
		methods: {
			// 返回
			goBack() {
				let returnurl = this.backUrl
				if (returnurl == 'back') {
					uni.navigateBack({ delta: 1 });
				} else {
					if (returnurl.indexOf('pages/home/index') >= 0 || returnurl.indexOf('pagesA/info/index') >= 0 || returnurl.indexOf('pages/my/index') >= 0 || returnurl.indexOf('pages/doctor/index') >= 0 || returnurl.indexOf('pages/doctor/my') >= 0) {
						uni.switchTab({ url: returnurl })
					} else {
						uni.redirectTo({ url: returnurl })
					}
				}
			}
		}
	}
</script>

<style lang="less">
	.topBar{
		width:750rpx;background-color: #fff;
		.status{width: 750rpx;}
	}
</style>
